package com.wzy.new_energy_car_platform.controller;


import com.wzy.new_energy_car_platform.common.ResultDto;
import com.wzy.new_energy_car_platform.service.CarCircleService;
import com.wzy.new_energy_car_platform.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * <p>
 * 车友圈 前端控制器
 * </p>
 *
 * @author wzy
 * @since 2024-04-09
 */
@RestController
@RequestMapping("/car_circle")
public class CarCircleController {
    @Autowired
    private CarCircleService carCircleService;

    @Autowired
    private PostService postService;

    @GetMapping("/getCarCircle")
    public ResultDto<?> getCarCircle(){
        return carCircleService.getCarCircle();
    }

    @GetMapping("/getPost")
    public ResultDto<?> getPost(){
         return postService.getPost();
    }


    @PostMapping ("/submitPost")
    public  ResultDto<?>  submitPost(@RequestBody Map map){
        String token = map.get("token").toString();
        String content = map.get("content").toString();
        return postService.submitPost(token,content);
    }

    @PostMapping("/uploadImg")
    public  ResultDto<?> uploadImg(@RequestBody  MultipartFile image){
        return postService.uploadImg(image);
     }

    @GetMapping("/getImg")
    public   byte[] getImg(String imgName){
          return  postService.getImg(imgName);
      }

}
